﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ChallengePuzzle.Lib
{
    /// <summary>
    /// 数组累加器
    /// </summary>
    public class PlusSum : ChallengePuzzle.Lib.IPlusSum
    {
        int PreValue = 0;

        public int GetPlusSum(int Number)
        {
            int LessNum = Number % 10;

            if (LessNum != 0)
            {
                PreValue++;
                return PreValue;
            }

            PreValue = GetPlusSum1(Number);

            return PreValue;

 
        }

       

        public PlusSum()
        {
           
        }

  

 

//--------------------------------------------------------------------------


        public int GetPlusSum1(int Number)
        {
            int DivNum = Number / 10;

            int LessNum = Number % 10;

            if (DivNum < 10) return DivNum + LessNum;

            return GetPlusSum1(DivNum) + LessNum;
        }






    }
}
